package com.atguigu.chaptar5

import scala.collection.mutable

object $09_MutableMap {
  def main(args: Array[String]): Unit = {
    //1.两种创建方法
    val map = mutable.Map[String, Int](("aa", 1), ("bb", 2), ("cc", 3))
    val map1 = mutable.Map[String, Int]("aa"->1,"bb"->2,"cc"->3)
    //2.添加元素
    val map2 = map.+("dd" -> 4)
    map.+=("ee"->5)
    map.++=(List("fs"->4,"fds"->432,"fdsf"->42))
      //put添加
    map.put("pp",18)
    //3.删除数据
    map.-=("pp")
    val map3 = map.--(List("ff", "浮点数", "方式"))
      //remove指定数据
    map.remove("fds")
    //4.获取数据
    map.getOrElse("fs",28)
    //5.修改元素
    map("aa")=200
      //update
    map.update("fds",42)
  }

}
